package com.jit.firsthibernate.facade;

import java.io.Console;
import java.sql.Date;

import com.jit.firsthibernate.dao.ProfileDAO;
import com.jit.firsthibernate.domain.Profile;

public class Main {
	
	enum Process {
		
		add{
			@Override
			public void handle() {
				Console console = System.console();
				Profile test=new Profile();
				test.setName(console.readLine());
				test.setSurname(console.readLine());
				test.setPhoneNumber(console.readLine());
				test.setBirthday(new Date(Long.parseLong(console.readLine())));
				ProfileDAO.getInstance().saveOrUpdateProfile(test);
			}
		},
		remove{
			@Override
			public void handle() {
				Console console = System.console();
				ProfileDAO.getInstance().deleteProfile(Integer.parseInt(console.readLine()));
			}
		},
		list{
			@Override
			public void handle() {
				System.out.println(ProfileDAO.getInstance().listProfiles());
			}
		},
		update{
			@Override
			public void handle() {
				
			}
		};
		
		public abstract void handle();
	}
	
	
	
	public static void main(String[] args) {
		Process.valueOf(args[0]).handle();
	}
}
